package cn.com.fig.dao;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import cn.com.fig.portal.domain.Department;
import org.springframework.stereotype.Repository;

@Mapper
@Repository
public interface DepartmentMapper {
	
	@Select("SELECT departId,departName,departStatus,parentId AS _parentId FROM t_department WHERE departId = #{departId}")
	Department get(String departId);
	/**
	 * 不分页方式查询数据
	 * @return
	 */
	@Select("SELECT departId,departName,departStatus,parentId AS _parentId FROM t_department")
	List<Map<String,Object>> listDepartment();
	
	@Insert("INSERT INTO	t_department(departId,departName,departStatus,parentId) VALUES("
			+ "#{departId, jdbcType=VARCHAR},#{departName, jdbcType=VARCHAR},#{departStatus, jdbcType=CHAR},#{parentId, jdbcType=VARCHAR});")
	int insert(Map<String, Object> map);
	
	@Update("UPDATE t_department SET departName = #{departName, jdbcType=VARCHAR},departStatus=#{departStatus, jdbcType=CHAR},"
			+ "parentId = #{parentId, jdbcType=VARCHAR} where departId = #{departId, jdbcType=VARCHAR}")
	int update(Map<String, Object> map);
	
	@Delete("delete from t_department where departId = #{departId}")
	int delete(@Param("departId") String departId);
}
